package com.netnovelstore.dao;

import com.netnovelstore.pojo.Book;
import com.netnovelstore.pojo.Message;
import com.netnovelstore.pojo.User;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
//@Mapper
public interface UserMapper {
    //    @Select("select * from tb_user where userName = #{username}")
    User Login(String username);

    Boolean setUserImgByUsername(String userName, String userImg);

    Boolean insertUser(User user);

    Integer isExistByUserName(String username);

    User getUserByNumber(Integer userNumber);

    Boolean updateUserByNumber(User user);

    Boolean delUserByNumberList(List<Integer> numberList);

    Integer getCountUser();

    List<User> getUserList(Integer pageStart, Integer pageSize);

    List<User> getUserByInfo(String keyword);

    @Select("select user_name from tb_user where user_number = #{userNumber} AND deleted =0")
    String selectUserNameByUserNumber(Integer userNumber);

    @Update("update tb_user set password = #{password} where user_number = #{userNumber}")
    Boolean updatePassword(Integer userNumber, String password);

    @Update("update tb_user set nick_name = #{nickName} where user_number = #{userNumber}")
    Boolean updateNickName(Integer userNumber, String nickName);

    @Update("update tb_user set user_img = #{userImg} where user_number = #{userNumber}")
    Boolean updateUserImg(Integer userNumber, String userImg);

    @Update("update tb_user set bookshelf = #{bookshelf} where user_number = #{userNumber}")
    Boolean updateBookshelf(Integer userNumber, Map<String, Book> bookshelf);

    @Update("update tb_user set unread = #{unread} where user_number = #{userNumber}")
    Boolean updateUnread(Integer userNumber, List<Message> unread);

    @Update("update tb_user set read = #{read} where user_number = #{userNumber}")
    Boolean updateRead(Integer userNumber, List<Message> read);

    @Update("update tb_user set hobby = #{hobby} where user_number = #{userNumber}")
    Boolean updateHobby(Integer userNumber, List<String> hobby);

    @Update("update tb_user set history = #{history} where user_number = #{userNumber}")
    Boolean updateHistory(Integer userNumber, Map<String, Book> history);


}
